import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Question13 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int a = in.nextInt();

        for (int i = 1; i < Integer.MAX_VALUE; i++) {
            int temp = i;

            int mul = 1;
            while (temp > 0) {
                int num = temp % 10;
                
                mul *= num;

                temp /= 10;
            }

            if (mul == a) {
                System.out.println(i);
                return ;
            }
        }

        System.out.println(0);
    }
}